CFLAGS=-Wno-error=narrowing
RM=rm -f
CP=cp 
MV=rename 
MKDIR=mkdir -p

PREFIX=cs1300\

LIBDIR=$(PREFIX)\lib
INCDIR=$(PREFIX)\include
BINDIR=$(PREFIX)\bin

libbgi.a: drawing.o misc.o mouse.o palette.o text.o winbgi.o winthread.o file.o dibutil.o winbgi.h winbgim.h graphics.h
	ar -rv libbgi.a drawing.o misc.o mouse.o palette.o text.o winthread.o winbgi.o file.o dibutil.o
	$(MKDIR) $(LIBDIR)
	$(RM) $(LIBDIR)\libbgi.a
	$(CP) libbgi.a $(LIBDIR)
	$(RM) $(INCDIR)\winbgi.h
	$(CP) winbgi.h $(INCDIR)

clean:
	$(RM) *.o 
	$(RM) *.exe 
	$(RM) libbgi.a

drawing.o: drawing.cxx winbgi.h winbgitypes.h
	g++ $(CFLAGS) -c drawing.cxx

misc.o: misc.cxx winbgi.h winbgitypes.h
	g++ $(CFLAGS) -c misc.cxx

mouse.o: mouse.cxx winbgi.h winbgitypes.h
	g++ $(CFLAGS) -c mouse.cxx

palette.o: palette.cxx winbgi.h winbgitypes.h
	g++ $(CFLAGS) -c palette.cxx

text.o: text.cxx winbgi.h winbgitypes.h
	g++ $(CFLAGS) -c text.cxx

winbgi.o: winbgi.cxx winbgi.h winbgitypes.h
	g++ $(CFLAGS) -c winbgi.cxx

winthread.o: winthread.cxx winbgi.h winbgitypes.h
	g++ $(CFLAGS) -c winthread.cxx

dibutil.o: dibutil.c dibutil.h dibapi.h
	g++ $(CFLAGS) -c dibutil.c

file.o: file.c dibutil.h dibapi.h winbgitypes.h
	g++ $(CFLAGS) -c file.c

graphics.h: winbgi.h
	$(RM) graphics.h
	$(CP) winbgi.h graphics.h
	$(RM) $(INCDIR)\graphics.h
	$(CP) graphics.h $(INCDIR)

winbgim.h: winbgi.h
	$(RM) winbgim.h
	$(CP) winbgi.h winbgim.h
	$(RM) $(INCDIR)\winbgim.h
	$(CP) winbgim.h $(INCDIR)
bgi.exe: bgi.cxx
	g++ bgi.cxx -o bgi
	$(RM) $(BINDIR)\bgi++.exe
	$(CP) bgi.exe $(BINDIR)
	$(MV) $(BINDIR)\bgi.exe bgi++.exe

